<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/5/26
  Time: 17:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="s" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sf" uri="http://www.springframework.org/tags/form" %>
<html>
<head>
    <title>权限修改</title>
    <script type="application/javascript">
        window.onload=function () {
            $("#powerLevel").hide();
            if("${msg}" == "update"){
            var savaForm=document.getElementById("saveForm");
            savaForm.action="${pageContext.request.contextPath}/Xzpower/updatePower.emp?realPowerId=${xzpower.realPowerId}"
            }
        }
        function ToPowerShowPage() {
            window.location.href="${pageContext.request.contextPath}/Xzpower/toPowerShowPage.emp";
        }
        
        //显示个模板级下的权限级
        function showPowerLevel() {
            var  myselect=document.getElementById("modelLevel");
            var index=myselect.selectedIndex;
            var myValue=  myselect.options[index].value;

            if(myValue == 0){
                $("#powerLevel").hide();
            }else {
                $("#powerLevel").show();
                $.ajax({
                    url:'${pageContext.request.contextPath}/Xzpower/selPowerLevel.emp',
                    data:{id:myValue},
                    success: function (data) {
                        $("#powerLevel").empty();
                        $('#powerLevel').append("<option value='0' name='powerNo'>--无权限级--</option>");

                        for(var i=0;i<data.PowerLevelList.length;i++){
                            /*拼接选择上级生成的下级元素*/
                            $('#powerLevel').append("<option path='"+data.PowerLevelList[i].powerNo+"'" +
                                "value='"+data.PowerLevelList[i].powerNo+"'>"+data.PowerLevelList[i].powerName+ "</option>");
                        }
                    }
                })
            }

        }
        
    </script>
</head>
<body>
<!--头部开始-->
<jsp:include page="headerBack.jsp"></jsp:include>
<!-- 导航 -->
<jsp:include page="leftBack.jsp"></jsp:include>
<!--内容页-->
<div class="main">
    <!--内容页头部-->
    <div class="page-header">
        <div class="pull-left">
            <ol class="breadcrumb visible-sm visible-md visible-lg">
                <li><a href="index.html"><i class="icon fa fa-home"></i>主页</a></li>
                <li class="active"><i class="fa fa-pencil"></i>权限编辑</li>
            </ol>
        </div>
        <div class="pull-right">
            <h2>主页</h2>
        </div>
    </div>

    <sf:form action="${pageContext.request.contextPath}/Xzpower/addPower.emp" class="search1"  method="post" modelAttribute="xzpower" id="saveForm">
          <div>
              <div>
              <select name="powerId" onchange="showPowerLevel()" id="modelLevel">
                  <option value="0" name="powerId">--无模块级--</option>
                  <s:forEach var="superPower" items="${superPowerList}">
                  <option path="${xzpower.powerId}" value="${superPower.powerId}" <c:if test="${superPower.powerNo == xzpower.superNo}">selected="selected"</c:if> >${superPower.powerName}</option>
                  </s:forEach>
              </select>
                  <%--<select id="powerLevel" name="superNo">--%>
                     <%--&lt;%&ndash;<s:forEach var="powerLevel" items="${powerLevelList}">&ndash;%&gt;--%>
                         <%--&lt;%&ndash;<option path="${xzpower.powerId}" value="${powerLevel.powerId}">${powerLevel.powerName}</option>&ndash;%&gt;--%>
                     <%--&lt;%&ndash;</s:forEach>&ndash;%&gt;--%>
                  <%--</select>--%>
              </div>
             <input type="hidden" class="realPowerId" value="${xzpower.realPowerId}"/>
              <div> 权限名称：<input type="text" name="powerName" value="${xzpower.powerName}"/> </div>
              <c:if test="${show.equals('show')}">
              <div>权限字符：<input type="text" name="powerCode" value="${xzpower.powerCode}"/></div>
              </c:if>
          </div>
        <button type="submit" class="btn btn-primary">提交</button>
        <button type="button" class="btn btn-primary" onclick="ToPowerShowPage()">取消</button>
    </sf:form>

</div>

</body>
</html>
